package com.iflytek.cosmo.ocr.support.license.client.v1;

import com.iflytek.cosmo.ocr.support.license.LicenseVersion;
import com.iflytek.cosmo.ocr.support.license.client.AbstractClientLicenseProcessor;
import com.iflytek.cosmo.ocr.support.license.client.ClientLicense;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Decoder;

/**
 * 版本1授权码生成器
 *
 * @author <a href=mailto:ktyi@iflytek.com>伊开堂</a>
 * @date 2021/2/3
 */
@Component
public class ClientLicenseProcessorV1 extends AbstractClientLicenseProcessor {

    @Override
    public ClientLicense decode(String license) {
        try {
            String licenseStr = decryptLicense(license);
            return new ClientLicenseV1(licenseStr);
        }
        catch (Exception e) {
            System.out.println("解密异常, 验证失败");
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public LicenseVersion supportVersion() {
        return LicenseVersion.V1;
    }
}

